package cn.edu.hqu.cst.android.ex3demo;

import android.content.res.Configuration;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;
import androidx.appcompat.app.AppCompatActivity;


/**
 * 获取系统设置
 *
 *
 */
public class SystemInfoActivity  extends AppCompatActivity {
    TextView tv_system_info_activity_ori,tv_system_info_activity_nav,tv_system_info_activity_touch,tv_system_info_activity_mnc;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_system_info);

        tv_system_info_activity_ori = findViewById(R.id.tv_system_info_activity_ori);
        tv_system_info_activity_nav = findViewById(R.id.tv_system_info_activity_nav);
        tv_system_info_activity_touch = findViewById(R.id.tv_system_info_activity_touch);
        tv_system_info_activity_mnc = findViewById(R.id.tv_system_info_activity_mnc);

                // 获得系统的Configuration对象
                Configuration config = getResources().getConfiguration();
                // 获得屏幕方向
                String screen = config.orientation == Configuration.ORIENTATION_LANDSCAPE ? "横屏"
                        : "竖屏";
                tv_system_info_activity_ori.setText(screen);
                // 获得移动信号的网络码
                String mncCode = config.mnc + "";
                tv_system_info_activity_mnc.setText(mncCode);
                // 获得系统上方向导航的设备类型
                String naviName = config.navigation == Configuration.NAVIGATION_NONAV ? "没有方向控制"
                        : config.navigation == Configuration.NAVIGATION_WHEEL ? "滚轮控制方向"
                        : config.navigation == Configuration.NAVIGATION_DPAD ? "方向键控制方向"
                        : "轨迹球控制方向";
                tv_system_info_activity_nav.setText(naviName);
                // 获得系统触摸屏的触摸方式
                String touchName = config.touchscreen == Configuration.TOUCHSCREEN_NOTOUCH ? "无触摸屏"
                        : config.touchscreen == Configuration.TOUCHSCREEN_STYLUS ? "触摸笔式的触摸屏"
                        : "接受手指的触摸屏";
                tv_system_info_activity_touch.setText(touchName);
            }

    }



